import { SongType } from './musicType'
export function formatMilliseconds(milliseconds: number) {
  const minutes = Math.floor(milliseconds / 60000)
  const seconds = Math.floor((milliseconds % 60000) / 1000)
  const minutesStr = minutes.toString().padStart(2, '0')
  const secondsStr = seconds.toString().padStart(2, '0')
  return `${minutesStr}:${secondsStr}`
}
export function fuzzySearchByName(items: SongType[], searchKeyword: string) {
  searchKeyword = searchKeyword.trim()
  return items.filter(
    (item) =>
      item.title.toLowerCase().includes(searchKeyword.toLowerCase()) ||
      item.title.toLowerCase().includes(searchKeyword.split('').join(''))
  )
}
